/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.emailsenderdemo;

import com.mycompany.emailsenderdemo.vo.EmailVO;
import javax.annotation.Resource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 *
 * @author Jeff
 */
@Service
public class SpringEmailService implements IEmailService {
    
    @Resource
    JavaMailSender javaMailSender;
    
    @Override
    public void sendMail(String content) {
        
    }
    
    @Override
    public void sendMail(EmailVO vo) {
        //TODO: the actual method who proceed the mailing logic
        SimpleMailMessage msg = new SimpleMailMessage();
        msg.setTo(vo.getTo());
        msg.setFrom(vo.getFrom());
        msg.setSubject(vo.getSubject());
        msg.setText(vo.getText());
        
        javaMailSender.send(msg);
    }

    @Override
    public void echo() {
        System.out.println("Hello Email Service!");
    }
    
    
}
